package com.parsec.sb.pattern.observer;

import com.parsec.sb.entity.User;

public class ObserverPattern {
    public static void main(String[] args) {
        User user = new User();
        user.setName("吕布");
        user.setAge(24);

        UserObservable observable = new UserObservable();
        AObserver aObserver = new AObserver();
        BObserver bObserver = new BObserver();
        CObserver cObserver = new CObserver();
        observable.addObserver(aObserver);
        observable.addObserver(bObserver);
        observable.addObserver(cObserver);
        observable.setChanged();
        observable.notifyObservers(user);
    }
}
